
// import * as d3 from "../lib/d3.js";
// import * as d3 from "d3";

// const table = JSON.parse(d3.select("#translations").text());

const table = {
  "% Visibility Chance": null,
  "(feels like)": null,
  "3-hour Precipitation Accumulation": "3小时累积降水量",
  "Carbon Dioxide Surface Concentration": "地表二氧化碳浓度",
  "Carbon Monoxide Surface Concentration": "地表一氧化碳浓度",
  "Convective Available Potential Energy from Surface": "对流可用位能（表面）",
  "Data download failed": null,
  "Data is empty": null,
  "Data not available for this date": null,
  "Dust Extinction (Aerosol Optical Thickness, 550 nm)": "尘埃消光（气溶胶光学厚度，550纳米）",
  "Finding current position is not supported": null,
  "Finding current position...": null,
  "Instantaneous Wind Power Density": "瞬时风电功率密度",
  "Mean Sea Level Pressure": "平均海平面压力",
  "Misery Index": "体感温度",
  "Network not available": null,
  "Ocean Currents": "洋流",
  "Particulate Matter < 1 µm": null,
  "Particulate Matter < 10 µm": null,
  "Particulate Matter < 2.5 µm": null,
  "Peak Wave Period": "波峰周期",
  "Probability of Visible Aurora": null,
  "Relative Humidity": "相对湿度",
  "Sea Surface Temperature Anomaly": "海面温度异常",
  "Sea Surface Temperature": "海面温度",
  "Significant Wave Height": "有效浪高",
  "Sulfate Extinction (Aerosol Optical Thickness, 550 nm)": "硫酸盐消光（气溶胶光学厚度，550纳米）",
  "Sulfur Dioxide Surface Mass": "地表二氧化硫总质量",
  "Surface": "近地面",
  "Temperature": "温度",
  "Total Cloud Water": "云中所含水汽总和",
  "Total Precipitable Water": "水汽含量",
  "Wind": "风",
  "year": "年",
  "month": "月",
  "week": null,
  "day": "日",
  "hour": null,
  "years": null,
  "months": null,
  "weeks": null,
  "days": null,
  "hours": null,
  "minutes": null,
  "N/A": null
};

/**
 * A string template processor that looks up and returns translations for the specified string.
 *
 * <pre>
 *     tr`Wind`  // "Vent"
 * </pre>
 *
 * @param {string[]} parts
 * @returns {string} the translated string
 */
export function tr(parts) {
    if (parts.length > 1) {
        throw new Error("NYI");  // substitutions not supported
    }
    const key = parts[0];  // parts.join("{i++}")
    return table[key] ?? key;
}
